package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @Title: UserController
 * @Package: com.project.controller
 * @Description:
 * @Author: Liang-Xie
 * @Date: 2022/6/28 - 11:36
 */
@SuppressWarnings("all")
@RestController
@RequestMapping()
public class UserController {
    @RequestMapping("login")
    public String login(String userName, String pwd, String code, HttpServletRequest req){
//        得到用户的session对象
        HttpSession session=req.getSession();
//        取出验证码
        String loginCode=session.getAttribute("loginCode").toString();
        if (code.equalsIgnoreCase(loginCode)==false){
            return "验证码错误";
        }

        if ("java".equals(userName)&&"123".equals(pwd)){
            return "ok";
        }else {
            return "no";
        }
    }
}
